package com.lanqiao.companymanage.config;

import com.lanqiao.companymanage.lnterceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 棍棍
 *  web 的相关配置
 *  例如 拦截器
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {


    @Autowired
    LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 把我们写好的拦截器加入到项目中,启动拦截器
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")//我们拦截所有请求
                .excludePathPatterns("/login/**");// 不拦截哪些请求
    }
}
